<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改工单管理')"/>
</head>
<body>
<form class="layui-form" th:object="${workOrder}">
    <div class="mainBox">
        <div class="main-container">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="layui-form-item">
                <label class="layui-form-label">标题：</label>
                <div class="layui-input-block">
                    <input type="text" name="title" th:field="*{title}"
                           placeholder="请输入标题" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">620 数量：</label>
                <div class="layui-input-block">
                    <input type="text" name="lowNum" th:field="*{lowNum}"
                           placeholder="请输入620 数量" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">650 数量：</label>
                <div class="layui-input-block">
                    <input type="text" name="highNum" th:field="*{highNum}"
                           placeholder="请输入650 数量" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">其他 数量：</label>
                <div class="layui-input-block">
                    <input type="text" name="otherNum" th:field="*{otherNum}"
                           placeholder="请输入其他 数量" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">配送人：</label>
                <div class="layui-input-block">
                    <input type="text" name="sender" th:field="*{sender}"
                           placeholder="请输入配送人" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">出库人：</label>
                <div class="layui-input-block">
                    <input type="text" name="invOutBy" th:field="*{invOutBy}"
                           placeholder="请输入出库人" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">接收者：</label>
                <div class="layui-input-block">
                    <input type="text" name="accepter" th:field="*{accepter}"
                           placeholder="请输入接收者" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">出库时间：</label>
                <div class="layui-input-block">
                    <div class="input-group date">
                        <input type="text" name="invOutTime" class="layui-input"
                               id="invOutTime">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">配送时间：</label>
                <div class="layui-input-block">
                    <div class="input-group date">
                        <input type="text" name="sendTime" class="layui-input"
                               id="sendTime">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">接收时间：</label>
                <div class="layui-input-block">
                    <div class="input-group date">
                        <input type="text" name="acceptTime" class="layui-input"
                               id="acceptTime">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工单状态：</label>
                <div class="layui-input-block">
                    <div class="radio-box" radio-dict-code="input"
                         th:attr="default-value=*{status}" name="status">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">抄送列表id：</label>
                <div class="layui-input-block">
                    <input type="text" name="carbonCopyList" th:field="*{carbonCopyList}"
                           placeholder="请输入抄送列表id" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">取货单位id：</label>
                <div class="layui-input-block">
                    <input type="text" name="invOutDept" th:field="*{invOutDept}"
                           placeholder="请输入取货单位id" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">收货单位id 去向部门id：</label>
                <div class="layui-input-block">
                    <input type="text" name="acceptDept" th:field="*{acceptDept}"
                           placeholder="请输入收货单位id 去向部门id" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">内容：</label>
                <div class="layui-input-block">
                    <input type="text" name="content" th:field="*{content}"
                           placeholder="请输入内容" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">修改人：</label>
                <div class="layui-input-block">
                    <input type="text" name="updateName" th:field="*{updateName}"
                           placeholder="请输入修改人" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工单发起人名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="createName" th:field="*{createName}"
                           placeholder="请输入工单发起人名称" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">配送人名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="senderName" th:field="*{senderName}"
                           placeholder="请输入配送人名称" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">出库人名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="invOutName" th:field="*{invOutName}"
                           placeholder="请输入出库人名称" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">接收人名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="accepterName" th:field="*{accepterName}"
                           placeholder="请输入接收人名称" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">取货部门名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="invOutDeptName" th:field="*{invOutDeptName}"
                           placeholder="请输入取货部门名称" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">收货部门名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="acceptDeptName" th:field="*{acceptDeptName}"
                           placeholder="请输入收货部门名称" class="layui-input"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否逻辑删除：</label>
                <div class="layui-input-block">
                    <input type="text" name="enable" th:field="*{enable}"
                           placeholder="请输入是否逻辑删除" class="layui-input"/>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="order-update">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
</body>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    layui.use(['form', 'jquery', 'laydate', 'dictionary'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;

        let prefix = "/work/order/";

        laydate.render({
            elem: '#invOutTime'
        });
        laydate.render({
            elem: '#sendTime'
        });
        laydate.render({
            elem: '#acceptTime'
        });

        form.on('submit(order-update)', function (data) {
            for (var key in data.field) {
                var type = $(data.form).find("input[name='" + key + "']").attr("type");
                if (type == "checkbox") {
                    var value = "";
                    $(data.form).find("input[name='" + key + "']:checked").each(function () {
                        value += $(this).val() + ",";
                    })
                    if (value != "") {
                        value = value.substr(0, value.length - 1);
                        data.field[key] = value;
                    }

                }
            }
            $.ajax({
                url: prefix + 'update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'put',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                            parent.layui.table.reload("order-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    });
</script>
</html>